<template>
  <el-form
    ref="elFormRef"
    label-width="auto"
    label-position="top"
    :rules="rules"
    :model="formData"
  >
    <el-form-item prop="name" label="审批模板名称">
      <el-input
        v-model="formData.name"
        placeholder="请填写节点名称"
      />
    </el-form-item>

    <el-form-item prop="type_id" label="审批类型">
      <el-select
        v-model="formData.type_id"
        placeholder="请选择"
        style="width: 100%;"
        disabled
      >
        <el-option
          v-for="item in approvalType"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  name: '',
  props: {
    formData: {
      type: Object,
      default: () => ({})
    },
    approvalType: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      rules: {
        name: [{ required: true, message: '审批模板名称不能为空', trigger: ['change', 'blur'] }],
        type_id: [
          { required: true, message: '审批类型不能为空', trigger: ['change', 'blur'] }
        ]
      }
    }
  },
  methods: {
    validate() {
      return new Promise((resolve, reject) => {
        this.$refs.elFormRef.validate((valid, invalidFields) => {
          if (valid) resolve(true)
          resolve(false)
        })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
